// -----------------------------
// Author: 		Dhaenens Gert	
// Creation: 	2/16/2015 7:30:51 PM				
// -----------------------------

#include "WindowEventHandler.h"

WindowEventHandler::WindowEventHandler()
{
}

void WindowEventHandler::RegisterEvents(CoreWindow^ refWindow)
{
	Window = refWindow;

	Window->Activated += ref new TypedEventHandler<CoreWindow ^, WindowActivatedEventArgs ^>(&WindowEventHandler::OnActivated);
	Window->Closed += ref new TypedEventHandler<CoreWindow ^, CoreWindowEventArgs ^>(&WindowEventHandler::OnClosed);
	Window->VisibilityChanged += ref new TypedEventHandler<CoreWindow ^, VisibilityChangedEventArgs ^>(&WindowEventHandler::OnVisibilityChanged);
}
void WindowEventHandler::Dispatch(CoreProcessEventsOption option)
{
	Window->Dispatcher->ProcessEvents(option);
}

void WindowEventHandler::OnActivated(CoreWindow ^sender, WindowActivatedEventArgs ^args)
{
	IsAlive = true;
}

void WindowEventHandler::OnClosed(CoreWindow ^sender, CoreWindowEventArgs ^args)
{
	IsAlive = false;
}

void WindowEventHandler::OnVisibilityChanged(CoreWindow ^sender, VisibilityChangedEventArgs ^args)
{
	IsVisible = args->Visible;
}